﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Hetang.Models.Helper
{
    /// <summary>
    /// 数据转换(GUID to Base64, Base64 to GUID)
    /// </summary>
    public class ConvertHelper
    {
        /// <summary>
        /// GuidToBase64
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public static string GuidToBase64(Guid guid)
        {
            return System.Convert.ToBase64String(guid.ToByteArray());
        }

        /// <summary>
        /// Base64ToGuid
        /// </summary>
        /// <param name="base64"></param>
        /// <returns></returns>
        public static Guid Base64ToGuid(string base64)
        {
            var bytes = System.Convert.FromBase64String(base64);
            return new Guid(bytes);
        }
    }
}